/**
 *  Copyright (C) 2010:
 *                 Buzzanca Marco <marco.bzn@gmail.com>
 *         Monaco Davide Giuseppe <black.ralkass@gmail.com>
 *              Petralia Veronica <veronicapetralia@gmail.com>
 *
 * This file is part of DS2011BMP
 *
 * DS2011BMP is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * DS2011BMP is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

/**
 * @file activity.h
 * @author Marco Buzzanca 
 *
 * This header file contains Activity class declaration.
 */

#ifndef _ACTIVITY_H_
#define _ACTIVITY_H_ 1

#include <iostream>

#include "tqproxyfactory.h"
#include "tqueuemanagerproxy.h"
#include "worker.h"
#include "workflow.h"
#include "workernetwork.h"

/**
 * @brief This class represents an activity in the distributed system.
 * A Manager creates a new Activity in order to schedule a Workflow over the
 * system associating it to a WorkerNetwork.
 */
class Activity
{
private:
  /**
   * @brief The Workflow associated to current Activity.
   */
  Workflow  _wf;

  /**
   * @brief The WorkerNetwork associated to current Activity.
   */
  WorkerNetwork _sbn;

  /**
   * @brief The factory used to obtain a TaskDescriptor Queue Proxy.
   */
  TQProxyFactory _tqpf;
public:
  /**
   * @brief Constructor used as Default one.
   * @param wf  The Workflow to associate current Activity to.
   * @param sbn The WorkerNetwork to associate current Activity to.
   */
  Activity(const Workflow& wf = Workflow(),
      const WorkerNetwork& sbn = WorkerNetwork());

  /**
   * @brief Destructor.
   */
  ~Activity(void);

  /**
   * @brief Returns the Workflow associated to current Activity.
   * @return  Current Workflow.
   */
  const Workflow& getWf(void) const;

  /**
   * @brief Set current Workflow to provided one.
   * @param wf  The provided Workflow. 
   */
  void setWf(const Workflow& wf);

  /**
   * @brief Returns the WorkerNetwork associated to current Activity.
   * @return  Current WorkerNetwork.
   */
  const WorkerNetwork& getSbn(void) const;

  /**
   * @brief Set current WorkerNetwork to provided one.
   * @param wf  The provided WorkerNetwork. 
   */
  void setSbn(const WorkerNetwork& sbn);

  /**
   * @brief Schedule an activity for execution.
   *
   * Through TQueueManagerProxy enqueue one TaskDescriptor contained
   * in the current Workflow into a Worker's queue.
   *
   * Please note that Discovery mechanisms have been already invoked by
   * Manager during WorkerNetwork creation.
   */
  void scheduleActivity(void);
};

#endif
